A former official of Pakistan's foreign office with links to the Shia group Tehrik-e-Islami has been detained by security agencies for his alleged connections with militants who carried out a suicide attack on a mosque in Rawalpindi frequented by military personnel.